package com.ruben.listener;

import java.util.HashMap;

import javax.annotation.Resource;

import org.springframework.data.redis.connection.Message;
import org.springframework.data.redis.connection.MessageListener;
import org.springframework.stereotype.Component;

import com.fasterxml.jackson.core.type.TypeReference;
import com.fasterxml.jackson.databind.ObjectMapper;

import lombok.SneakyThrows;

/**
 * @author <achao1441470436@gmail.com>
 * @since 2022/5/8 15:52
 */
@Component
public class RedisMessageListener implements MessageListener {

    @Resource
    private ObjectMapper objectMapper;

    /**
     * Callback for processing received objects through Redis.
     *
     * @param message message must not be {@literal null}.
     * @param pattern pattern matching the channel (if specified) - can be {@literal null}.
     */
    @Override
    @SneakyThrows
    public void onMessage(Message message, byte[] pattern) {
        System.out.println("接收到消息：" + new String(message.getBody()));
    }
}
